# Compiler settings.
MAKE		:= $(MAKE) --no-print-directory
CC			= gcc
CXX			= g++
CFLAGS		= -g -O2 -pipe
CXXFLAGS	= $(CFLAGS) -std=c++11 -pthread
PROTOC		= _depends/protobuf/bin/protoc -I_depends/protobuf/include

# Default include search paths.
INCLUDES	= -I$(CURDIR)/_depends/engine/include \
	-I$(CURDIR)/_depends/protobuf/include \
	-I$(CURDIR)/_depends/mysql/include \
	-I$(CURDIR)/_depends/libredis/include \
	-I$(CURDIR)/libnet

# Default library search paths.
LDFLAGS		= -L$(CURDIR)/_depends/engine/lib \
	-L$(CURDIR)/_depends/protobuf/lib \
	-L$(CURDIR)/_depends/mysql/lib \
	-L$(CURDIR)/_depends/libredis/lib \
	-L$(CURDIR)/libnet/lib

# Base path for generated objects.
OUTPUTDIR	= $(CURDIR)/../publish
BUILDDIR	= $(CURDIR)/../build

# Export all settings.
export CC CXX CFLAGS CXXFLAGS INCLUDES LDFLAGS OUTPUTDIR BUILDDIR

all:
	@cd libnet; $(MAKE)
	@cd zone; $(MAKE)
	@cd dbflush; $(MAKE)
	@cd dbproxy; $(MAKE)
	@cd logserver; $(MAKE)
	@cd login; $(MAKE)
	@cd center; $(MAKE)
	@cd game; $(MAKE)

proto:
	@$(PROTOC) -Ilibnet/protocols/proto_files --cpp_out=libnet/protocols libnet/protocols/proto_files/*.proto

gc:
	@cd center; $(MAKE)

gs:
	@cd game; $(MAKE)

clean:
	@cd libnet; $(MAKE) clean
	@cd zone; $(MAKE) clean
	@cd dbflush; $(MAKE) clean
	@cd dbproxy; $(MAKE) clean
	@cd logserver; $(MAKE) clean
	@cd login; $(MAKE) clean
	@cd center; $(MAKE) clean
	@cd game; $(MAKE) clean
